commit: Fix crash if dfd_iter is NULL
authorAlexander Larsson <alexl@redhat.com>
Wed, 13 Apr 2016 19:18:19 +0000 (21:18 +0200)
committerColin Walters (automation) <walters+githubbot@verbum.org>
Wed, 13 Apr 2016 19:37:06 +0000 (19:37 +0000)
in write_directory_content_to_mtree_internal dfd_iter can be NULL,
for instance if commiting from --tree=ref=FOO. Don't blindly de-ref
it to avoid crashing.

Closes: #256
Approved by: cgwalters

src/libostree/ostree-repo-commit.c

index 0fb3b0fe945ce6cf6080cd50af8e02b4f05bc32e..7f03e11d21b040da8dff959a0da88e6ba04793af 100644 (file)
@@ -2525,7 +2525,7 @@ write_directory_content_to_mtree_internal (OstreeRepo                  *self,
             }
 
           if (!get_modified_xattrs (self, modifier,
-                                    child_relpath, child_info, child, dfd_iter->fd, name,
+                                    child_relpath, child_info, child, dfd_iter != NULL ? dfd_iter->fd : -1, name,
                                     &xattrs,
                                     cancellable, error))
             goto out;